package com.masterclient.app.businessmodule.minemodule.contract;

import com.eoner.baselib.presenter.ThrowableConsumer;
import com.masterclient.app.httpservice.RetrofitUtil;
import com.eoner.baselibrary.bean.personal.CollectVideoBean;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/07/24
*/
public class VideoListPresenter extends VideoListContract.Presenter{

    @Override
    public void getCollectVideoList(String page, String page_size) {
        Observable<CollectVideoBean> observable = RetrofitUtil.getInstance().getCollectVideoList(page,page_size);

        Disposable disposable = toSubscribe(observable, new Consumer<CollectVideoBean>() {
            @Override
            public void accept(@NonNull CollectVideoBean bean) throws Exception {
                if("0".equals(bean.getCode())){
                    mView.showCollectVideoList(bean.getData());
                }
            }
        }, new ThrowableConsumer());

        mRxManager.add(disposable);
    }
}